{{include file="user/u_header.html"}}
<div class="w998 u_main clear">
	{{include file="user/u_leftMenu.html"}}	
    <!--右侧开始-->
    <div class="Fr right">
<script type="text/javascript" src="res/js/lhgcalendar/lhgcalendar.min.js"></script>
<script type="text/javascript">
$(function(){ 
    $('#starttime').calendar({ maxDate:'%y-%M-%d' });
    $('#endtime').calendar({ minDate:'#starttime',maxDate:'%y-%M-%d' });
});
</script>

        <div>
        <form action="user.php" method="get"> 
            <input type="hidden" name="ctl" value="deal">
            投资时间:
            <input class="runcode" name="starttime" id="starttime" value="{{$smarty.get.starttime}}" />
            到<input class="runcode" name="endtime" id="endtime" value="{{$smarty.get.endtime}}" />
         <!--    <a href="#">最近7天</a>
            <a href="#">1个月</a>
            <a href="#">2个月</a>
            <a href="#">3个月</a> -->
             <input type="submit">
         </form>
            期限:
            <a href="user.php?ctl=deal&repaytime=0&page={{$smarty.get.page}}&starttime={{$smarty.get.starttime}}&endtime={{$smarty.get.endtime}}">不限</a>
            <a href="user.php?ctl=deal&repaytime=1&page={{$smarty.get.page}}&starttime={{$smarty.get.starttime}}&endtime={{$smarty.get.endtime}}">3-6个月</a>
            <a href="user.php?ctl=deal&repaytime=2&page={{$smarty.get.page}}&starttime={{$smarty.get.starttime}}&endtime={{$smarty.get.endtime}}">9-15个月</a>
            <a href="user.php?ctl=deal&repaytime=3&page={{$smarty.get.page}}&starttime={{$smarty.get.starttime}}&endtime={{$smarty.get.endtime}}">18-24个月</a>
            <a href="user.php?ctl=deal&repaytime=4&page={{$smarty.get.page}}&starttime={{$smarty.get.starttime}}&endtime={{$smarty.get.endtime}}">24个月以上</a>
        </div>

        <table width="100%" border="0" cellspacing="0" cellpadding="0">
               <tbody><tr>
                <th width="" height="40">项目名称 </th>
                <th width="">项目编号 </th>
                <th width="">项目金额 </th>
                <th width="">投资金额 </th>
                <th width="">年化收益率 </th>
                <th width="">投资期限</th>
                <th width="">进度</th>
                <th width="">剩余时间/状态</th>
              </tr>
              {{foreach from=$res.data item=item  key=key}}
                  <tr>
                  <td><a href="index.php?ctl=deal&act=bid&id={{$item.DEAL_ID}}">{{$products_arr[$item.ADEAL_ID]["TITLE"]}}</a></td>
                    <td>{{$products_arr[$item.ADEAL_ID]["CODE"]}}</td>
                    <td>{{$products_arr[$item.ADEAL_ID]["PRICE"]}}元 </td>
                    <td>{{$item.MONEY}}元 </td>
                    <td>{{$products_arr[$item.ADEAL_ID]["RATE"]}}%</td>
                    <td>{{$products_arr[$item.ADEAL_ID]["REPAY_TIME"]}}个月</td>
                    <td><div class="progressbar progressbar-{{$item.loading}}"><span>{{$products_arr[$item.ADEAL_ID]["loading"]}}</span>%</div></td>
                    <td>
                        {{if $products_arr[$item.ADEAL_ID]["DEAL_STAT"]==2}}
                            <p id="time_{{$key}}"></p><div style="DISPLAY: none" id="sec_left_{{$key}}" class="time_left">{{$products_arr[$item.ADEAL_ID]["stime"]}}0</div>
                            <br/>
                        {{/if}}
                         {{$deal_stat[$products_arr[$item.ADEAL_ID]["DEAL_STAT"]]}}
                    </td>
                  </tr>
              {{/foreach}}
                </tbody>
        </table>
        <div class="page_center">{{$res.page}}</div>
    </div>
    <!--右侧结束-->
</div>
<link rel="stylesheet" type="text/css" href="res/css/progressbar.css">
<script type="text/javascript">
$(function() {
    $('.progressbar').each(function(index, el) {
        var num = $(this).find('span').text();
        $(this).addClass('progressbar-' + num);
    });
});
</script>
<script type="text/javascript">
      var second =null; 
      var minite = null; 
      var hour = null; 
      var day = null; 
      var seconds = null;
      var sec = {};
      function getInitTime(){
          $('.time_left').each(function(){
             var jobj = $(this);
             var SysSecond = parseInt(jobj.text());
             var theid = parseInt((jobj.attr('id')).replace(/sec_left_/,''));
             sec[theid]= SysSecond;
          });
      }
      getInitTime();
      function SetRemainTime() {
            for(var i in sec){
                setRemainTimeSite(i,sec[i]);
            }
       }
      function setRemainTimeSite(theid,SysSs){
          seconds = SysSs/10;
          second = Math.floor(seconds % 60).toString();
          minite = Math.floor((seconds / 60) % 60).toString();
          hour = Math.floor((seconds / 3600) % 24).toString();
          day = Math.floor((seconds / 3600) / 24).toString();
          if (SysSs >= 0) {
               var ss = Math.floor(SysSs % 10).toString();
               if(SysSs % 10==0){
                  seconds = SysSs/10;
                  second = Math.floor(seconds % 60).toString();
                  minite = Math.floor((seconds / 60) % 60).toString();
                  hour = Math.floor((seconds / 3600) % 24).toString();
                  day = Math.floor((seconds / 3600) / 24).toString();
               }
               $("#time_"+theid).html(day + "天" + hour + "小时" + minite + "分" + second + "秒."+ss);
               sec[theid]--;
               SysSs--;
          }else{
            return;
          }
        }
      window.setInterval(SetRemainTime,100);
</script>
{{include file="user/u_footer.html"}}
